// import { asyncRouterMap } from '@/router'
const state = {
  userInfo: sessionStorage.getItem('userInfo') ? JSON.parse(sessionStorage.getItem('userInfo')) : null,
  routers: localStorage.getItem('routers') ? JSON.parse(localStorage.getItem('routers')) : null,
  buttonsPer: localStorage.getItem('buttonsPer') ? JSON.parse(localStorage.getItem('buttonsPer')) : null
}
const getters = {
  gettersUserInfo(state) {
    return state.userInfo
  },
  gettersRouters(state) {
    return state.routers
  },
  gettersButtonsPer(state) {
    return state.buttonsPer
  }
}
const mutations = {
  loginMutations(state, params) {
    state.userInfo = params
    sessionStorage.setItem('userInfo', JSON.stringify(state.userInfo))
  },
  routersMutations(state, params) {
    state.routers = params || []
    localStorage.setItem('routers', JSON.stringify(state.routers))
  },
  buttonsMutations(state, params) {
    state.buttonsPer = params || []
    localStorage.setItem('buttonsPer', JSON.stringify(state.buttonsPer))
  }
}
const actions = {
  loginAction({ commit }, params) {
    commit('loginMutations', params)
  },
  routersAction({ commit }, data) {
    commit('routersMutations', data)
  },
  buttonsAction({ commit }, data) {
    commit('buttonsMutations', data)
  }
}
export default {
  state,
  getters,
  mutations,
  actions
}
